﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharpHomeEngine;

namespace Insteon.Requests
{
    public class AllLinkCommand : InsteonRequest
    {
        public readonly byte Group;
        public readonly byte Command;

        public AllLinkCommand(Controller Controller, InsteonInterface DeviceInterface, byte Group, byte Command)
            : base(Controller, DeviceInterface)
        {
            this.Group = Group;
            this.Command = Command;
        }

        internal override void BeginExecute()
        {
            Commands.Insteon.AllLinkCommand CMD = new Commands.Insteon.AllLinkCommand(Group, Command);
            CMD.InsteonRequest = this;
            InsteonInterface.QueueCommand(CMD);
        }

        internal override void CommandCompleted(Commands.Command CMD)
        {
            if (CMD is Commands.Insteon.AllLinkCommand)
            {
                Commands.Command Cmd = (Commands.Insteon.AllLinkCommand)CMD;
                this.Complete(Cmd.isComplete, Cmd.isSuccessful);
            }
            else
            {
                this.Fail();
            }
        }
    }
}
